<extend name="Public/common" />
<tagLib name="Editor"/>
<block name="body">
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>商品管理</h3>
      <ul class="tab-base">
        	<li><a href="{:U('index')}"><span>列表</span></a></li>
	        <li><a href="{:U('add')}"><span>新增</span></a></li>
	        <li><a href="JavaScript:void(0);" class="current"><span>编辑</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <form id="form1" method="post" enctype="multipart/form-data" name="form1">
    <input type="hidden" name="goods_id" value="{$info['goods_id']}" />
    <table class="table tb-type2">
      <tbody>
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="goods_name">商品名称:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="{$info['goods_name']}" name="goods_name" id="goods_name" class="txt"></td>
          <td class="vatop tips">商品名称</td>
        </tr>
        
        <tr>
          <td colspan="2" class="required"><label class="validation" for="goods_sn">货号:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="{$info['goods_sn']}" name="goods_sn" id="goods_sn" class="txt"></td>
          <td class="vatop tips">商品的货号或者编号，可以自定义填写，也可以不该动系统生成</td>
        </tr>
        
        <tr>
          <td colspan="2" class="required"><label class="validation" for="goods_desc">商品简介:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><textarea name="goods_desc" rows="6" class="tarea" id="goods_desc" style="width: 400px;height: 100px">{$info['goods_desc']}</textarea></td>
          <td class="vatop tips"><span class="vatop rowform">商品的简介描述，可以把突出重点的文字放在此处，不支持富文本，用户商品搜索</span></td>
        </tr>

        <tr>
          <td colspan="2" class="required"><label class="validation" for="goods_combo">套餐包含:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="{$info['goods_combo']}" name="goods_combo" id="goods_combo" class="txt"></td>
          <td class="vatop tips">套餐包含 不要复制回车符</td>
        </tr>

        <tr>
          <td colspan="2" class="required"><label for="thumb">图片:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><span class="type-file-show"><img class="show_image" src="__IMG__/preview.png">
            <div class="type-file-preview"><img src="{$info['goods_image']}"></div></span>
            <span class="type-file-box"><input type='text' name='textfield' id='textfield1' class='type-file-text' /><input type='button' name='button' id='button1' value='' class='type-file-button' />
            <input name="goods_image" type="file" class="type-file-file" id="goods_image" size="30" hidefocus="true" nc_type="change_goods_image">
            </span></td>
          <td class="vatop tips"><span class="vatop rowform">商品图片500px *500px 系统支持的图片格式为:gif,jpg,jpeg,png，用于列表，推荐等地方</span></td>
        </tr>
                
        <tr>
          <td colspan="2" class="required"><label class="validation" for="market_price">市场价格:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="{$info['market_price']}" name="market_price" id="market_price" class="txt"></td>
          <td class="vatop tips">堂食价格</td>
        </tr> 
                <tr>
          <td colspan="2" class="required"><label class="validation" for="shop_price">堂食价格:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="{$info['shop_price']}" name="shop_price" id="shop_price" class="txt"></td>
          <td class="vatop tips">抢购价格</td>
        </tr> 
        <tr>
          <td colspan="2" class="required"><label class="validation" for="member_price">会员价格:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="{$info['member_price']}" name="member_price" id="member_price" class="txt"></td>
          <td class="vatop tips">会员价格</td>
        </tr> 

        <tr>
          <td colspan="2" class="required"><label class="validation" for="store_id">所属商户:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><select name="store_id" id="store_id">
              <option value="">商户名称</option>
		      <notempty name="store">
		      <volist name="store" id="vo">
              <option <eq name="info.store_id" value="$key">selected='selected'</eq> value="{$key}">{$vo}</option>
              </volist>
              </notempty>
            </select></td>
          <td class="vatop tips">商户名称</td>
        </tr> 
                       
        <tr>
          <td colspan="2" class="required"><label for="video_content">商品详情:</label></td>
        </tr>
        <tr class="noborder">
          <td colspan="2" class="vatop rowform"><editor:editor id="goods_content" name="goods_content" upload="1" media="1" type="all">{$info['goods_content']}</editor:editor></td>
        </tr>
                
        
        <tr>
          <td colspan="2" class="required"><label for="click">查看次数:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="{$info['goods_click']}" name="goods_click" id="goods_click" class="txt"></td>
          <td class="vatop tips">查看详情的次数</td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="share">销售次数:</label></td>
        </tr>  
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="{$info['goods_sale']}" name="goods_sale" id="goods_sale" class="txt"></td>
          <td class="vatop tips">销售的次数</td>
        </tr>   
      </tbody>
      <tfoot>
        <tr class="tfoot">
          <td colspan="15" ><a href="JavaScript:void(0);" class="btn" id="submit"><span>提交</span></a></td>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
<script type="text/javascript" src="__JS__/fileupload/jquery.iframe-transport.js" charset="utf-8"></script> 
<script type="text/javascript" src="__JS__/fileupload/jquery.ui.widget.js" charset="utf-8"></script> 
<script type="text/javascript" src="__JS__/fileupload/jquery.fileupload.js" charset="utf-8"></script> 
<script type="text/javascript">
$(document).ready(function(){
	$('#form1').validate({
        errorPlacement: function(error, element){
			error.appendTo(element.parent().parent().prev().find('td:first'));
        },
        rules : {
        	goods_name : {
                required : true
            },
            goods_desc : {
                required : true
            },
            goods_combo : {
                required : true
            },
            store_id : {
                required : true
            },
            market_price : {
                required : true,
                number   : true
            },
            shop_price : {
                required : true,
                number   : true
            },
            member_price : {
                required : true,
                number   : true
            },
            goods_click : {
                number   : true
            },
            goods_sale : {
                number   : true
            }
        },
        messages : {
        	goods_name : {
        		required : "商品名称必须填写"
            },
            goods_desc : {
                required : "商品描述简介必须填写"
            },
            goods_combo : {
                required : "套餐包含必须填写"
            },
            store_id : {
                required : "所属商户必须填写"
            },
            market_price : {
                required : "商品市场价格必须填写",
                number   : "商品市场价格必须是数字"
            },
            shop_price : {
                required : "商品食堂价格必须填写",
                number   : "商品食堂价格必须是数字"
            },
            member_price : {
                required : "商品会员价格必须填写",
                number   : "商品会员价格必须是数字"
            },
            goods_click : {
                number   : "必须是数值"
            },
            goods_sale : {
                number   : "必须是数值"
            }
        }
    });

	$("#goods_image").change(function() {
		$("#textfield1").val($(this).val());
	});
	$('input[class="type-file-file"]').change(function() {
		var filepatd = $(this).val();
		var extStart = filepatd.lastIndexOf(".");
		var ext = filepatd.substring(extStart, filepatd.lengtd).toUpperCase();
		if (ext != ".PNG" && ext != ".GIF" && ext != ".JPG" && ext != ".JPEG") {
			alert("图片限于png,gif,jpeg,jpg格式");
			$(this).attr('value', '');
			return false;
		}
	});
	$("#submit").click(function() {
		if ($("#form1").valid()) {
			$("#form1").submit();
		}
	});
});
</script>
</block>